package com.zx.mobile.utils;

import com.zx.map.service.AgentInfoService;
import com.zx.map.service.model.AgentInfoModel;
import com.zx.map.service.model.MerchantInfoDetailModel;
import com.zx.mobile.SessionHelper;
import com.zx.mobile.context.ApplicationContextUtil;
import com.zx.mobile.domain.MobileUserDomain;
import com.zx.platform.service.domain.ManageSessionDomain;
import com.zx.platform.service.model.OperatorInfoModel;

import javax.servlet.http.HttpServletRequest;

public class WebUtils {

	/**
	 * 获取当前登录的用户，代理商信息
	 * @param request
	 * @return
	 */
	public static AgentInfoModel queryCurrentLoginAgentInfo(HttpServletRequest request){
		MobileUserDomain mobileUserDomain = queryCurrentLoginInfo(request);
		AgentInfoService agentInfoService = (AgentInfoService) ApplicationContextUtil.getContext().getBean("agentInfoService");
		AgentInfoModel curAgentInfoModel = agentInfoService.getAgentInfoModelBySysAccount(mobileUserDomain.getMerchantInfoDetailModel().getSysAccount());
		return curAgentInfoModel;
	}
	/**
	 * 获取当前登录用户的信息
	 * @param request
	 * @return
	 */
	public static MobileUserDomain queryCurrentLoginInfo(HttpServletRequest request){
		MobileUserDomain user = (MobileUserDomain) request.getSession()
				.getAttribute(SessionHelper.MOBILEUSER);
		 return user;
	}

	public static MerchantInfoDetailModel queryCurrentLoginMerchantInfoDetailModel(HttpServletRequest request){
		MobileUserDomain user = (MobileUserDomain) request.getSession()
				.getAttribute(SessionHelper.MOBILEUSER);
		return user.getMerchantInfoDetailModel();
	}
}
